package com.xxx.seckill.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: xxx
 * @Date: 2023/1/10 21:09
 * @Description: rabbitmq 秒杀商品 配置类
 */
@Configuration
public class RabbitMQSeckillConfig {
    
    private static final String QUEUE="seckillQueue";
    private static final String EXCHANGE="seckillExchange";


    /**
     * 准备队列
     * @return
     */
    @Bean
    public Queue queueSeckill(){
        return new Queue(QUEUE);
    }

    /**
     * 准备交换机  主题模式交换机
     * @return
     */
    @Bean
    public TopicExchange topicExchangeSeckill(){
        return new TopicExchange(EXCHANGE);
    }
    
    
    @Bean
    public Binding binding(){
        return BindingBuilder.bind(queueSeckill()).to(topicExchangeSeckill()).with("seckill.#");
    }
    
    
    
}
